/* listBankLib.h - list bank library header file*/

/* Copyright 2003-2005 Neotune Information Technology Co., Ltd. */

#ifndef __INClistBankLibh
#define __INClistBankLibh

#ifdef __cplusplus
extern "C" {
#endif

#include "neos_vx_win.h"
#include "iterLib.h"

/* status codes */
#define S_listBankLib_INVALID_ID         (M_listBankLib | 1)
#define S_listBankLib_INVALID_NLISTS     (M_listBankLib | 2)
#define S_listBankLib_INVALID_NELEMENTS (M_listBankLib | 3)
#define S_listBankLib_INVALID_SIZE         (M_listBankLib | 4)
#define S_listBankLib_ALLOC_ERROR         (M_listBankLib | 5)
#define S_listBankLib_INVALID_NODE        (M_listBankLib | 6)
#define S_listBankLib_INVALID_INDEX        (M_listBankLib | 7)
#define S_listBankLib_SORTED_ONLY        (M_listBankLib | 8)
#define S_listBankLib_INVALID_TYPE        (M_listBankLib | 9)
#define S_listBankLib_NODES_EXHAUSTED    (M_listBankLib | 10)

/* type definitions */

typedef ulong_t LIST_BANK_ID;

IMPORT LIST_BANK_ID    listBankCreate
    ( 
    void *address,
    ulong_t nLists,
    ulong_t nElements,
    ulong_t elemSize,
    ulong_t type,
    BUFCFUNCPTR createFn,
    BUFCFUNCPTR destroyFn,
    CMPFUNCPTR compareFn,
    ulong_t createArgVal,
    ulong_t compareArgVal
    );
IMPORT STATUS listBankDestroy( LIST_BANK_ID bank );
IMPORT void *listBankAllocNode( LIST_BANK_ID bank );
IMPORT STATUS listBankFreeNode( LIST_BANK_ID bank, void *node );
IMPORT STATUS listBankDeleteNode( LIST_BANK_ID bank, ulong_t index, void *node );
IMPORT void *listBankAddNode( LIST_BANK_ID bank, ulong_t index, void *node );
IMPORT void *listBankMoveNode
    ( 
    LIST_BANK_ID bank,
    ulong_t fromIndex,
    ulong_t toIndex,
    void *node,
    void *insertAfter
    );
IMPORT void *listBankInsertNode
    ( 
    LIST_BANK_ID bank,
    ulong_t index,
    void *node,
    void *insertAfter
    );
IMPORT void *listBankFirstNode( LIST_BANK_ID bank, ulong_t index );
IMPORT void *listBankLastNode( LIST_BANK_ID bank, ulong_t index );
IMPORT void *listBankNextNode( LIST_BANK_ID bank, void *node );
IMPORT void *listBankPrevNode( LIST_BANK_ID bank, void *node );
IMPORT ulong_t listBankNumberOfLists( LIST_BANK_ID bank );
IMPORT ulong_t listBankNodeCount(LIST_BANK_ID bank, ulong_t index);
IMPORT void listBankNodeDeleteCallback( void *objAddr, ulong_t index, ulong_t argVal );
IMPORT ulong_t listBankGetMemSize
    ( 
    ulong_t nLists, 
    ulong_t nElements, 
    ulong_t elemSize, 
    ulong_t type 
    );
#else   /* __STDC__ */
IMPORT LIST_BANK_ID    listBankCreate();
IMPORT void *listBankAllocNode( );
IMPORT STATUS listBankFreeNode( );
IMPORT STATUS listBankDeleteNode( );
IMPORT void *listBankAddNode( );
IMPORT void *listBankMoveNode( );
IMPORT void *listBankInsertNode( );
IMPORT void *listBankFirstNode( );
IMPORT void *listBankLastNode( );
IMPORT void *listBankNextNode( );
IMPORT void *listBankPrevNode( );
IMPORT ulong_t listBankNumberOfLists( );
IMPORT ulong_t listBankNodeCount( );
IMPORT void listBankNodeDeleteCallback( );
IMPORT ulong_t listBankGetMemSize( );

/*
* These macros are defined as a convenience; you may use the iterLib functions
* to iterate through any listBank list, but these macros do the typecast
* to ITER_HEADER * for you.
*/
#define listBankSearchForNode(a,b,c,d,e,f) \
    iterSearchForEntry((ITER_HEADER *)a,b,c,d,e,f)
#define listBankForEachNode(a,b,c,d,e) \
    iterForEachEntry((ITER_HEADER *)a,b,c,d,e) 
#define listBankForEachNodeUntil(a,b,c,d,e,f) \
    iterForEachEntryUntil((ITER_HEADER *)a,b,c,d,e,f) 
#define listBankForSelectedNodes(a,b,c,d,e,f,g,h) \
    iterForSelectedEntries((ITER_HEADER *)a,b,c,d,e,f,g,h)

#ifdef __cplusplus
}
#endif

#endif

